<#--
List of variables to be passed for this template:
        +- rootPackage
        +- applicationName
        +- classNames
        +- directory
        +- Entities: ArrayList of EntityClass.getAsMap()

            |
            +- imports: imports
            |
            +- name: The name of the class.
            |    |
            |    +- single
            |    +- plural
            |
            +- idColumn: the id column
            |    |
            |    +- field
            |    |    |
            |    |    +- name
            |    |    +- type
            |    |
            |    +- getter
            |    +- setter
            |
            +- columns: ArrayList of columns
            |    |
            |    +- field
            |    |    |
            |    |    +- name
            |    |    +- type
            |    |    +- hasTypeParameter
            |    |    +- typeParameter -- only if hasTypeParameter returns true!
            |    +- getter
            |    +- setter

-->

<@pp.dropOutputFile />
<#list Entities as entity>
<@pp.changeOutputFile name="/development/${directory}/apis/models/${entity.name.plural}.java" />

package ${rootPackage}.${applicationName}.apis.models;

import com.nanosn.coffeemaker.datebase.api.Controller;
import java.util.List;
import ${rootPackage}.${applicationName}.models.${entity.name.single};

/**
 * Plays with Google App Engine rules
 */
public class ${entity.name.plural} extends Controller<${entity.name.single}> {

    @Override
    public ${entity.name.single} find(Object primaryKey) {
        return this.find(${entity.name.single}.class, primaryKey);
    }

    @Override
    public List<${entity.name.single}> Query(${entity.name.single} entity) {
        return this.Query(this.Query(${entity.name.single}.class, entity));
    }

    @Override
    public Object persist(${entity.name.single} entity) {
        this._persist(entity);
        return entity.${entity.idColumn.getter}();
    }
}
</#list>